﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using Provausio.Common.Objects;
using TrainingManagement.api.Models.BusinessObjects;
using Provausio.Common.Utility.Extensions;

namespace TrainingManagement.api.Models.Data.Readers
{
    public class DepartmentTreeDataReader : BusinessOperation<IDataRecord, DepartmentTree>
    {
        public override DepartmentTree Run(IDataRecord input)
        {
            var tree = new DepartmentTree
                {
                    LocationId = input["LocationID"].DbTo<int>(),
                    LocationTitle = input["Location"].ToString(),
                    ChildId = input["ChildId"].DbTo<int>(),
                    ChildTitle = input["Child"].ToString(),
                    ParentId = input["ParentId"].DbTo<int>(),
                    ParentTitle = input["Parent"].ToString()
                };
            return tree;
        }
    }
}